/// @tags:
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

typedef long long LL;

int const N = 1e7 + 5, mod = 1e9 + 7;

int fac[N], inv[N];

inline int main() {
  int T, n;
  cin >> T;
  fac[0] = 1;
  for (int i = 1; i < N; ++i) fac[i] = (LL)fac[i - 1] * i % mod;
  inv[N - 1] = 792381967;
  for (int i = N - 2; i >= 0; --i) inv[i] = (LL)inv[i + 1] * (i + 1) % mod;
  while (T--) {
    cin >> n;
    int ans = fac[n];
    for (int i = 1, lim = n / 2; i <= lim; ++i) {
      int tmp = fac[n - i] * 2LL % mod - fac[n - i * 2];
      if (tmp < 0) tmp += mod;
      if ((ans -= tmp) < 0) ans += mod;
    }
    for (int i = n / 2 + 1; i < n; ++i) {
      if ((ans -= fac[n - i]) < 0) ans += mod;
    }
    cout << ans << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("game.in", "r", stdin);
  freopen("game.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
